
<template>
  <div>
    <router-view></router-view>
  </div>
</template>
<script setup>
import sideNav from './components/sider-nav.vue'
import Import from './components/import.vue'
const success = ({header, result}) => {
  const tableInfo = {
    '姓名': 'name',
    '卡号': 'cardNo'
  }
  let newArr = result.map(item => {
    let personnelInfo = {}
    Object.keys(item).forEach(key => {
      if (tableInfo[key] === 'timeOfEntry' || tableInfo[key] === 'correctionTime') {
        // 后端接口 限制了 不能是字符串 要求转化时间类型
        personnelInfo[tableInfo[key]] = new Date(formatDate(item[key], '/')) // 只有这样 才能存入数据库
      } else {
        personnelInfo[tableInfo[key]] = item[key] // 将原来中文对应的值 赋值给原来英文对应的值
      }
    })
    return personnelInfo
  })
  console.log(newArr,'newArr')
}
// 转化excel的日期格式
const formatDate = (numb, format) => {
  const time = new Date((numb - 1) * 24 * 3600000 + 1)
  time.setYear(time.getFullYear() - 70)
  const year = time.getFullYear() + ''
  const month = time.getMonth() + 1 + ''
  const date = time.getDate() - 1 + ''
  if (format && format.length === 1) {
    return year + format + month + format + date
  }
  return year + (month < 10 ? '0' + month : month) + (date < 10 ? '0' + date : date)
}
</script>

<style scoped>
</style>
